<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use App\Utils\VideoUtil;

class DownloadVideoJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $videoUrl;
    protected $savePath;
    protected $fileName;

    /**
     * Create a new job instance.
     */
    public function __construct($videoUrl, $savePath, $fileName)
    {
        //
        $this->videoUrl = $videoUrl;
        $this->savePath = $savePath;
        $this->fileName = $fileName;
    }

    /**
     * Execute the job.
     */
    public function handle(): void
    {
        //
        VideoUtil::download_video(
            $this->videoUrl,
            $this->savePath,
            $this->fileName
        );
    }
}
